# -*- coding: utf-8 -*-
from wox import Wox, WoxAPI
import webbrowser


class Main(Wox):

    def query(self, keyword):
        results = list()
        results.append({
            "Title": keyword,
            "SubTitle": "在百度搜索",
            "IcoPath": "Images/bd.png",
            "JsonRPCAction": {
                "method": "openBd",
                "parameters": [keyword],
                "dontHideAfterAction": False      # 运行后是否隐藏Wox窗口
            }
        })
        results.append({
            "Title": keyword,
            "SubTitle": "在Google搜索",
            "IcoPath": "Images/chrome.png",
            "JsonRPCAction": {
                "method": "openGoogle",
                "parameters": [keyword],
                "dontHideAfterAction": False      # 运行后是否隐藏Wox窗口
            }
        })
        return results

    def test_func(self, keyword):
        pass

    def openBd(self, url):
        webbrowser.open("https://www.baidu.com/s?wd="+url)

    def openGoogle(self, url):
        webbrowser.open("https://www.google.com.hk/search?q="+url)


if __name__ == "__main__":
    Main()
